]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
lookingGlass: Recognize new extensions as they are added
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 11 Jun 2011 04:21:35 +0000 (00:21 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 4 Aug 2011 17:40:04 +0000 (13:40 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=654770

js/ui/extensionSystem.js
js/ui/lookingGlass.js

index f722007fccbcc16c49d57b0faf52953745c7f846..0d7b199c78965777a1a5f10fd9390dbe7f229e02 100644 (file)
@@ -1,5 +1,8 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
+const Lang = imports.lang;
+const Signals = imports.signals;
+
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const St = imports.gi.St;
@@ -29,6 +32,15 @@ var enabledExtensions;
 // GFile for user extensions
 var userExtensionsDir = null;
 
+// We don't really have a class to add signals on. So, create
+// a simple dummy object, add the signal methods, and export those
+// publically.
+var _signals = {};
+Signals.addSignalMethods(_signals);
+
+const connect = Lang.bind(_signals, _signals.connect);
+const disconnect = Lang.bind(_signals, _signals.disconnect);
+
 /**
  * versionCheck:
  * @required: an array of versions we're compatible with
@@ -166,6 +178,8 @@ function loadExtension(dir, enabled, type) {
         return;
     }
     extensionMeta[meta.uuid].state = ExtensionState.ENABLED;
+
+    _signals.emit('extension-loaded', meta.uuid);
     global.log('Loaded extension ' + meta.uuid);
 }
 
index 65ca7ad3c774533df92e862bbb27b163593a7929..bafcb3721c73fa545b7fcc47b47f99b08df13636 100644 (file)
@@ -638,23 +638,32 @@ Extensions.prototype = {
                                         name: 'lookingGlassExtensions' });
         this._noExtensions = new St.Label({ style_class: 'lg-extensions-none',
                                              text: _("No extensions installed") });
+        this._numExtensions = 0;
         this._extensionsList = new St.BoxLayout({ vertical: true,
                                                   style_class: 'lg-extensions-list' });
+        this._extensionsList.add(this._noExtensions);
         this.actor.add(this._extensionsList);
-        this._loadExtensionList();
+
+        for (let uuid in ExtensionSystem.extensionMeta)
+            this._loadExtension(null, uuid);
+
+        ExtensionSystem.connect('extension-loaded',
+                                Lang.bind(this, this._loadExtension));
     },
 
-    _loadExtensionList: function() {
-        let extensions = ExtensionSystem.extensionMeta;
-        let totalExtensions = 0;
-        for (let uuid in extensions) {
-            let extensionDisplay = this._createExtensionDisplay(extensions[uuid]);
-            this._extensionsList.add(extensionDisplay);
-            totalExtensions++;
-        }
-        if (totalExtensions == 0) {
-            this._extensionsList.add(this._noExtensions);
-        }
+    _loadExtension: function(o, uuid) {
+        let extension = ExtensionSystem.extensionMeta[uuid];
+        // There can be cases where we create dummy extension metadata
+        // that's not really a proper extension. Don't bother with these.
+        if (!extension.name)
+            return;
+
+        let extensionDisplay = this._createExtensionDisplay(extension);
+        if (this._numExtensions == 0)
+            this._extensionsList.remove_actor(this._noExtensions);
+
+        this._numExtensions ++;
+        this._extensionsList.add(extensionDisplay);
     },
 
     _onViewSource: function (actor) {
@@ -691,7 +700,7 @@ Extensions.prototype = {
                                    text: meta.name });
         box.add(name, { expand: true });
         let description = new St.Label({ style_class: 'lg-extension-description',
-                                         text: meta.description });
+                                         text: meta.description || 'No description' });
         box.add(description, { expand: true });
 
         let metaBox = new St.BoxLayout();